Execute the following code:
# make a directory named tmp
mkdir tmp
# move into tmp
cd tmp
# add an empty file named tmp_file
touch tmp_file
# add an empty directory named another_tmp
mkdir another_tmp
# add an empty file to another_tmp directory
touch another_tmp/another_tmp_file
tmp_fileanother_tmp_file to
such_a_cool_filetmp directory and all its contents7 minutes.
In your breakout group, write bash code that executes each of the
following. * find “To be, or not to be” and write the contents of this
monologue to a file speech.txt (hint: the speech is 35
lines) * make a file called greatest_hits.txt that
includes: * the “To be, or not to be” speech * the line that includes
“know not what we may be” * all lines that include the word “doubts” or
“Doubts” * replaces all instances of the string “doubts” with
“uncertainties” in your greatest_hits.txt file (hint:
sed or awk)
???
sed and awk are more flexible than
grep, but I find the syntax very cryptic and difficult to
remember. I often have to Google to remind myself how it works.
~ 10-15 min
Write a script that * uses curl to download the text of
Romeo and Juliet from Project Gutenberg * http://www.gutenberg.org/files/1112/1112.txt ; * counts
the number of lines for characters Romeo (“Rom.”), Juliet (“Jul.”), and
the Apothecary (“Apoth.”); * saves a plain text file that for each of
these characters says: * “[character] has
[num] lines”.
Hints: use for loops